import React from 'react';
import { getformvaluejsonbyapplicationno } from '@/services/flowMine/apply';

const initValueJson = { formValueJson: {}, offerFile: [], workflowFile: [] };

/**
 * 获取表单详情
 */
const useFormDetail = applicationNo => {
    const [valueJson, setValueJson] = React.useState(initValueJson);
    const [loading, setLoading] = React.useState(false);
    React.useEffect(() => {
        if (applicationNo) {
            const fetchValueJson = async () => {
                setLoading(true);
                const result = await getformvaluejsonbyapplicationno(applicationNo);
                setLoading(false);
                if (result.code === 10000) {
                    console.log('===============================================>Json 表单详情', result.data);
                    setValueJson(result.data);
                }
            };

            fetchValueJson();
        }
    }, [applicationNo]);

    return [valueJson, loading];
};

export default useFormDetail;
